#include <ObjectInspectorVisitorChangeBackgroundOsg.h>
#include <iostream>
#include <ObjectInspectorItem.h>
#include <OsgClassDataSource/NodeOsg.h>
ObjectInspectorVisitorChangeBackgroundOsg::ObjectInspectorVisitorChangeBackgroundOsg() : ObjectInspectorVisitor()
{
    m_backgroundBrush = QBrush(QColor(65,65,65), Qt::BrushStyle::HorPattern);
}

ObjectInspectorVisitorChangeBackgroundOsg::~ObjectInspectorVisitorChangeBackgroundOsg()
{

}

void ObjectInspectorVisitorChangeBackgroundOsg::apply(QStandardItem *item)
{
    ObjectInspectorItem* objItem = dynamic_cast<ObjectInspectorItem*>(item);
    if(objItem != NULL)
    {
        //item->setBackground(m_backgroundBrush);
        NodeOsg* nodeOsg = dynamic_cast<NodeOsg*>(objItem->getObjectPtr().data());
        if(nodeOsg != NULL)
        {
            if(nodeOsg->getDisplay() == false)
            {
                item->setBackground(QBrush(QColor(65,65,65), Qt::BrushStyle::HorPattern));
            }
            else
            {
                item->setBackground(QBrush(QColor(197,214,245)));
            }
        }
        else
        {
            ObjectOsg* objOsg = dynamic_cast<ObjectOsg*>(objItem->getObjectPtr().data());
            if(objOsg != NULL)
            {
                item->setBackground(QBrush(QColor(197,214,245)));
            }

        }
    }
}

void ObjectInspectorVisitorChangeBackgroundOsg::setBackgroundBrush(const QBrush &brush)
{
    m_backgroundBrush = brush;
}
